Skip to content

Conversation

@lposen
Copy link
Contributor

@lposen lposen commented Nov 13, 2025

🔹 JIRA Ticket(s) if any

✏️ Description

Adds a logout helper to Iterable

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

Lines Statements Branches Functions
Coverage: 58%
58.36% (328/562) 33.03% (75/227) 56.58% (116/205)

@qltysh
Copy link

qltysh bot commented Nov 13, 2025

Diff Coverage: The code coverage on the diff in this pull request is 100.0%.

Total Coverage: This PR will increase coverage by 0.46%.

File Coverage Changes
Path File Coverage Δ Indirect
src/core/classes/Iterable.ts 0.4
🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

This is from Qlty Cloud, the successor to Code Climate Quality. Learn more.

Copy link
Member

@Ayyanchira Ayyanchira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with some suggestions in test file regarding email and userID flow

Iterable.savedConfig.authHandler!()
.then((promiseResult) => {
// Promise result can be either just String OR of type AuthResponse.
// Promise result can be either just String OR of type AuthRespronse.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spell mistake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! I'm guessing that I pressed r to refresh the app, but was focused here
instead of the terminal

IterableEventName.handleCustomActionCalled
);
RNEventEmitter.removeAllListeners(IterableEventName.handleAuthCalled);
Iterable.removeAllEventListeners();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catching all in one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +903 to +919
static logout() {
Iterable.removeAllEventListeners();
Iterable.setEmail(null);
Iterable.setUserId(null);
}

/**
* Removes all event listeners for the Iterable SDK.
*/
private static removeAllEventListeners() {
RNEventEmitter.removeAllListeners(IterableEventName.handleUrlCalled);
RNEventEmitter.removeAllListeners(IterableEventName.handleInAppCalled);
RNEventEmitter.removeAllListeners(IterableEventName.handleCustomActionCalled);
RNEventEmitter.removeAllListeners(IterableEventName.handleAuthCalled);
RNEventEmitter.removeAllListeners(IterableEventName.handleAuthSuccessCalled);
RNEventEmitter.removeAllListeners(IterableEventName.handleAuthFailureCalled);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Comment on lines +100 to +102
Iterable.setEmail('[email protected]');
Iterable.setUserId('user123');
// WHEN Iterable.logout is called
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email and userId usually dont go together.
When email is set and we call setUserId, it goes through logging out user with email id and then tries to log in.
So it should ideally be setEmail > logout > assernull for email

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I know.. this doesn't call the internal functionality for setting user id
and email, so I'm just doing this as a test to make sure that both are cleared
later. I'll add a comment to address this.

@lposen lposen merged commit 8a66205 into jwt/master Nov 14, 2025
6 of 7 checks passed
@lposen lposen deleted the jwt/SDK-149-add-logout-functionality branch November 14, 2025 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants